package ru.urfc.portal.ui.client.renderers.colorers;

import ru.urfc.portal.ui.client.Style;
import ru.urfc.portal.ui.client.descriptor.GridField;
import ru.urfc.portal.ui.client.widgets.MegaGrid;

import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.dom.client.Element;

public abstract class BaseColorer {

	protected GridField field;
	protected Element element;
	protected Style style;
	
	public BaseColorer(GridField field, Element element, Style style) {
		this.field = field;
		this.element = element;
		this.style = style;
	}
	
	public String colorCell(String text, ModelData modelData) {
		colorElements(modelData);
		element.setInnerText(text);
		return element.getParentElement().getInnerHTML();
	}

	public abstract void colorElements(ModelData modelData);

	public void init(MegaGrid grid) {
		element = grid.getCatalogItemTemplate();
		style = grid.getStyle();
	}
	
}
